/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __PSRAMX_H
#define __PSRAMX_H

#ifdef __cplusplus
 extern "C" {
#endif 

/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "spi.h"
	 
/** @addtogroup BSP
  * @{
  */ 

/** @addtogroup Components
  * @{
  */ 
  
/** @addtogroup PSRAM
  * @{
  */

/** @defgroup PSRAM_Exported_Types
  * @{
  */
   
/**
  * @}
  */ 

/** @defgroup PSRAM_Exported_Constants
  * @{
  */
   
/** 
  * @brief  PSRAMX Configuration  
  */  
#define PSRAM_TIMEOUT_VALUE 1000

/** 
  * @brief  PSRAMX Commands  
  */  
/* Reset Operations */
#define RESET_ENABLE_CMD                     0x66
#define RESET_MEMORY_CMD                     0x99
#define PAGE_PROG_CMD                        0x02
/* Identification Operations */
#define READ_ID_CMD                          0x9f

/* Read Operations */
#define READ_CMD                             0x03
#define FAST_READ_CMD                        0x0B





#define PSRAM_Enable() 			HAL_GPIO_WritePin(F_CS_GPIO_Port, F_CS_Pin, GPIO_PIN_RESET)
#define PSRAM_Disable() 		HAL_GPIO_WritePin(F_CS_GPIO_Port, F_CS_Pin, GPIO_PIN_SET)

#define PSRAM_OK            ((uint8_t)0x00)
#define PSRAM_ERROR         ((uint8_t)0x01)


typedef struct
{
	uint32_t FLASH_Id;
	uint32_t FLASH_Size;
	uint32_t PAGE_SIZE;
}PSRAM_Parameter;
extern PSRAM_Parameter PSRAM_Para;

uint8_t PSRAM_Init(void);
static void	PSRAM_Reset(void);
void PSRAM_Read_ID(uint16_t *ID);
uint8_t PSRAM_Read(uint8_t* pData, uint32_t ReadAddr, uint32_t Size);
uint8_t PSRAM_fast_Read(uint8_t* pData, uint32_t ReadAddr, uint32_t Size);
uint8_t PSRAM_Write(uint8_t *Data, uint32_t WriteAddr,uint16_t size);
uint8_t PSRAM_Get_Parameter(void);
/**
  * @}
  */
  
/** @defgroup PSRAM_Exported_Functions
  * @{
  */ 
/**
  * @}
  */ 
      
/**
  * @}
  */ 

/**
  * @}
  */ 

/**
  * @}
  */
  
#ifdef __cplusplus
}
#endif

#endif /* __PSRAM_H */

